<?php
if($_POST['sourcetype']==''||$_POST['major']=='-1')
{
    fs_showmsg('请选择专业和资源类型');
}
header("Cache-control:   private");
?>
<script type="text/javascript">
 function checkLogin()
 {
     alert('请登录系统后再进行操作');
     return false;
 }
</script>
<div id="indexcates">
        <div class="row-fluid" >
            <ul class="breadcrumb">
                <li>
        <?php
        switch($_POST['sourcetype']){
           case 1:$name='视频';echo '视频资源列表';break;
           case 2:$name='课件';echo '课件列表';break;
           case 3:$name='考试';echo '考试列表';break;
           case 4:$name='练习';echo '练习题列表';break;   
           default:'';break;
   }
        ?>
        </li>
            </ul>
        </div>			
        <div class="exam_list" style="padding-bottom: 10px;margin-top: 0;">
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    
                    <?php
                        if($_POST['sourcetype']==1)
                        {
                            $sql = "select v.id as v_id,v.title,m.realname as realname,v.intotime,v.photo as photo,v.introduction as introduction,v.times as times from ".DBPREFIX."videos as v inner join nettteach_member as m on v.belonger=m.id   where v.state=0 and m.majorid =".$_POST['major'];
                            if($_POST['content'] !="请输入关键字"&&$_POST['content']!='')
                            {
                                $sql.=" and v.title like '%".$_POST['content']."%'";
                            }
                            $result = $db -> query($sql);
                            ?>
                    <thead><tr><th>缩略图</th><th>视频标题</th><th>简介</th><th>浏览次数</th><th>发布时间</th><th>上传人</th></tr></thead>
                        <tbody>
                    <?php
                            while($row=$db->fetch_array($result)){      
                    ?>
                        <tr valign="middle">
                            <td style="width: 15%"><a href="<?php echo ('teacher/'.$row['photo'])?>"><img src="<?php echo ('teacher/'.$row['photo'])?>" onerror= "javascript:this.src= 'teacher/uploadfiles/image/nopic.jpg ' "  width="90" border="0" alt=""> </a></td>
                            <td style="width: 15%;padding-left: 1%;" ><a title="点击查看" <?php if($_SESSION['sid']==''){echo 'href="#" onclick="checkLogin()"';}else{echo 'href="?do=viewvideos&video_id='.$row['v_id'].'"';}?> ><?php echo $row['title']?></a></td>
                            <td style="width: 35%;padding-left: 2%;padding-right: 2%" title="<?php echo ($row['introduction'])?>"><?php echo (sub_str($row['introduction'],52))?> </td>
                            <td style="width: 10%"><?php echo($row['times'])?></td>  		
                            <td style="width: 10%"><?php echo(date('Y-m-d',$row['intotime']))?></td>
                            <td style="width: 10%" align="center"><?php echo $row['realname']?></td>
                        </tr>
                    <?php
                            }
                    }
                    elseif($_POST['sourcetype']==2){
                        $sql = "select c.id as id,c.writerid as writerid,m.realname as realname,c.title as title,c.times as times,c.intotime as intotime,c.introduction as introduction,c.size as size from ".DBPREFIX."courseware as c inner join nettteach_member as m on c.writerid=m.id   where c.state=0 and m.majorid =".$_POST['major'];
                        if($_POST['content'] !="请输入关键字"&&$_POST['content']!='')
                            {
                                $sql.=" and c.title like '%".$_POST['content']."%'";
                            }
                        $result = $db -> query($sql);
                        ?>
                    <thead><tr><th>课件标题</th><th>简介</th><th>课件大小</th><th>下载次数</th><th>发布时间</th><th>上传人</th><th>操作</th></tr></thead>
                        <tbody>
                    <?php
                        while($row=$db->fetch_array($result)){?>
                            <tr valign="middle">
                            <td style="width: 18%;padding-left: 2%" ><?php echo $row['title']?></td>
                            <td style="width: 30%;" title="<?php echo ($row['introduction'])?>"><?php echo (sub_str($row['introduction'],52))?> </td>
                            <td style="width: 10%" align="center"><?php echo $row['size']?>M</td>  
                            <td style="width: 10%" align="center"><?php echo $row['times']?></td>  
                            <td style="width: 10%" align="center"><?php echo(date('Y-m-d',$row['intotime']))?></td>  
                            <td style="width: 8%" align="center"><?php echo $row['realname']?></td>
                            <td style="width: 10%" align="center" ><input type="button"  <?php if($_SESSION['sid']==''){echo 'onclick="checkLogin()"';}else{echo 'onclick="godownload('.$row['id'].')"';}?> class="kaoshi" value="点击下载" /></td>
                        </tr>
                <?php
                        }
                    }
                    elseif($_POST['sourcetype']==3){
                        $sql = "select e.exam_id as exam_id,e.exam_time as time,e.exam_name as exam_name,e.exam_pubtime as exam_pubtime,m.realname as realname from ".DBPREFIX."exam as e inner join nettteach_member as m on e.exam_pubuid=m.id   where m.majorid =".$_POST['major']." and e.type=1";;
                        if($_POST['content'] !="请输入关键字"&&trim($_POST['content'])!='')
                            {
                                $sql.=" and e.exam_name like '%".$_POST['content']."%'";
                            }
                        $result = $db -> query($sql);
                        ?>
                    <thead><tr><th>试卷名称</th><th>考试时间</th><th>上传时间</th><th>上传人</th><th>操作</th></tr></thead>
                        <tbody>
                    <?php
                        while($row=$db->fetch_array($result)){?>
                        <tr valign="middle">
                            <td style="width: 50%;padding-left: 2%" ><a <?php if($_SESSION['sid']==''){echo 'href="#" onclick="checkLogin()"';}else{echo 'href="?do=examinfo&id='.$row['exam_id'].'"';}?>><?php echo $row['exam_name']?></a></td>
                            <td width="12%" align="center"><?php echo $row['time']?>分钟</td>   
                            <td width="12%" align="center"><?php echo(date('Y-m-d',$row['exam_pubtime']))?></td>
                            <td width="12%" align="center"><?php echo $row['realname']?></td>    
                            <td width="12%" align="center" ><input type="button" <?php if($_SESSION['sid']==''){echo 'onclick="checkLogin()"';}else{echo 'onclick="goexam('.$row['exam_id'].')"';}?> class="kaoshi" value="进入考试" /></td>
                        </tr>
                <?php
                        }
                    }
                    elseif($_POST['sourcetype']==4){
                        $sql = "select e.exam_id as exam_id,e.exam_num as time,e.exam_name as exam_name,e.exam_pubtime as exam_pubtime,m.realname as realname from ".DBPREFIX."exam as e inner join nettteach_member as m on e.exam_pubuid=m.id   where m.majorid =".$_POST['major']." and e.type=0";
                        if($_POST['content'] !="请输入关键字"&&$_POST['content']!='')
                            {
                                $sql.=" and e.exam_name like '%".$_POST['content']."%'";
                            }
                        $result = $db -> query($sql);
                        ?>
                    <thead><tr><th>试卷名称</th><th>做题人数</th><th>上传时间</th><th>上传人</th><th>操作</th></tr></thead>
                        <tbody>
                    <?php
                        while($row=$db->fetch_array($result)){?>
                         <tr valign="middle">
                            <td style="width: 50%;padding-left: 2%" ><a <?php if($_SESSION['sid']==''){echo 'href="#" onclick="checkLogin()"';}else{echo 'href="?do=exerciseinfo&id='.$row['exam_id'].'"';}?>><?php echo $row['exam_name']?></a></td>
                            <td width="12%" align="center"><?php echo $row['time']?></td>   
                            <td width="12%" align="center"><?php echo(date('Y-m-d',$row['exam_pubtime']))?></td>
                            <td width="12%" align="center"><?php echo $row['realname']?></td>    
                            <td width="12%" align="center" ><input type="button" <?php if($_SESSION['sid']==''){echo 'onclick="checkLogin()"';}else{echo 'onclick="gotest('.$row['exam_id'].')"';}?> class="kaoshi" value="进入练习" /></td>
                        </tr>
                <?php
                        }
                    }
                    else
                    {
                        echo '没有找到您搜索的内容!';
                    }?>

                        
                    </tbody>
                </table>
        </div>  
</div>
<script type="text/javascript">
    function gotest(examid){
        window.location.href = '?do=exerciseinfo&id='+examid;
    }
    function goexam(examid){
        window.location.href = '?do=examinfo&id='+examid;
    }
    function godownload(dowloadid)
    {
        window.location.href = 'main/courseware/download_courseware.php?courseware_id='+dowloadid;
    }
</script>
